import pandas as pd
import matplotlib as mpl

import matplotlib.pyplot as plt
from matplotlib import colors
import csv

csv_file = "/home/iris/Project/r/whole_MammaryGland.Lactation/expression.csv"
csv_data = pd.read_csv(csv_file, low_memory = False,header=0, usecols=['tsne1', 'tsne2',"X0610007P14Rik"])#防止弹出警告
csv_df = pd.DataFrame(csv_data)

with open(csv_file, 'r') as csvfile:
    reader = csv.reader(csvfile)
    for i, rows in enumerate(reader):
        if i == 0:
            row = rows
            break
    print(row)


def colormap():
    return mpl.colors.LinearSegmentedColormap.from_list('cmap', ['#9e9e9e', '#ef6c00'], 256)

# norm = colors.Normalize(vmin=csv_df.min("X0610007P14Rik"), vmax=csv_df.max("X0610007P14Rik"))
plt.scatter(csv_df["tsne1"], csv_df["tsne2"], c = csv_df["X0610007P14Rik"], cmap=colormap(), alpha=0.8)

cb = plt.colorbar(orientation='horizontal')
cb.set_label('Gene expression level')
plt.title("X0610007P14Rik")
plt.xlabel("t-SNE1")
plt.ylabel("t-SNE2")

# plt.legend("l")
plt.show()


# ————————————————
# 版权声明：本文为CSDN博主「立志成为摄影师的健身虾」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
# 原文链接：https://blog.csdn.net/weekdawn/java/article/details/81389234